#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout,QLabel, QPushButton, QApplication)
from PyQt5.QtGui import QFont    
import tushare as ts
 
 
class Example(QWidget):
    
    def __init__(self):
        super().__init__()
        
        self.initUI()
        
        
    def initUI(self):

        df = ts.get_index()
        print(df)

        lbl1 = QLabel(df.name[0], self)
        lbl1.move(15, 20)
 
        lbl2 = QLabel(str(df.change[0]), self)
        lbl2.move(15, 40)

        close = '{0:.2f}'.format(df.close[0])
        lbl3 = QLabel(close, self)
        lbl3.move(15, 60)

        lbl4 = QLabel(str(df.amount[0]), self)
        lbl4.move(15, 80)
        #################################
        lbl1 = QLabel(df.name[12], self)
        lbl1.move(15, 120)
 
        lbl2 = QLabel(str(df.change[12]), self)
        lbl2.move(15, 140)

        close = '{0:.2f}'.format(df.close[12])
        lbl3 = QLabel(close, self)
        lbl3.move(15, 160)

        lbl4 = QLabel(str(df.amount[12]), self)
        lbl4.move(15, 180)
        ####################################
        lbl1 = QLabel(df.name[17], self)
        lbl1.move(15, 220)
 
        lbl2 = QLabel(str(df.change[17]), self)
        lbl2.move(15, 240)

        close = '{0:.2f}'.format(df.close[17])
        lbl3 = QLabel(close, self)
        lbl3.move(15, 260)

        lbl4 = QLabel(str(df.amount[17]), self)
        lbl4.move(15, 280)
                
        ####################################
        lbl1 = QLabel(df.name[8], self)
        lbl1.move(15, 320)
 
        lbl2 = QLabel(str(df.change[8]), self)
        lbl2.move(15, 340)

        close = '{0:.2f}'.format(df.close[8])
        lbl3 = QLabel(close, self)
        lbl3.move(15, 360)

        lbl4 = QLabel(str(df.amount[8]), self)
        lbl4.move(15, 380)

        ####################################
        lbl1 = QLabel(df.name[10], self)
        lbl1.move(15, 420)
 
        lbl2 = QLabel(str(df.change[10]), self)
        lbl2.move(15, 440)

        close = '{0:.2f}'.format(df.close[10])
        lbl3 = QLabel(close, self)
        lbl3.move(15, 460)

        lbl4 = QLabel(str(df.amount[10]), self)
        lbl4.move(15, 480)

        ####################################
        lbl1 = QLabel(df.name[11], self)
        lbl1.move(15, 520)
 
        lbl2 = QLabel(str(df.change[11]), self)
        lbl2.move(15, 540)

        close = '{0:.2f}'.format(df.close[11])
        lbl3 = QLabel(close, self)
        lbl3.move(15, 560)

        lbl4 = QLabel(str(df.amount[11]), self)
        lbl4.move(15, 580)
        
         


        okButton = QPushButton("OK")
        cancelButton = QPushButton("Cancel")
 
        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)
 
        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(hbox)
        
        self.setLayout(vbox)    
        
        self.setGeometry(200, 200, 650,650)
        self.setWindowTitle('MyFund')    
        self.show()
        
        
if __name__ == '__main__':
    
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
